package com.vvv.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vvv.common.BaseResponse;
import com.vvv.model.dto.CourseQueryRequest;
import com.vvv.model.entity.CourseInfo;
import com.vvv.service.CourseInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author vvv
 * @date 2023-12-08 16 54
 * discription
 */
@RestController
@RequestMapping("/course")
public class CourseController {

    @Resource
    private CourseInfoService courseInfoService;


    @GetMapping("/start/grabbing")
    public BaseResponse<Boolean> startGrabbing() {
        courseInfoService.startGrabbing();
        return BaseResponse.success(true);
    }

    @PostMapping("/list/page")
    public BaseResponse<Page<CourseInfo>> listCourseByPage(@RequestBody CourseQueryRequest courseQueryRequest) {
        Page<CourseInfo> courseInfoPage =  courseInfoService.listCourseByPage(courseQueryRequest);
        return BaseResponse.success(courseInfoPage);
    }
}
